//-------------------------------------------------------------------
//	Copyright (c) 2012-2014 Zhirnov Andrey
//	This file is part of the "UXGEN-ES" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#pragma once

#include "UI/Systems/Screen.h"
#include "UI/Systems/ActionManager.h"
#include "UI/Systems/LocaleManager.h"
#include "UI/Resources/UITextureManager.h"

// Loaders //
#include "UI/Loaders/UILoader.h"


namespace Engine
{
namespace UI
{

	//
	// User Interface
	//

	class UserInterface : public BaseObject
	{
	// variables
	private:
		UITextureManager	_texMngr;
		UILoader			_uiLoader;

		ScreenPtr			_currentScreen;
		ActionManager		_actionMngr;
		LocaleManager		_localeMngr;


	// methods
	public:
		UserInterface (const EngineSubSystemsRef ess);
		~UserInterface ();

		void InitResources ();

		UITextureManager *	GetTextureManager ()		{ return &_texMngr; }
		UILoader *			GetUILoader ()				{ return &_uiLoader; }
		ActionManager *		GetActionManager ()			{ return &_actionMngr; }
		LocaleManager *		GetLocaleManager ()			{ return &_localeMngr; }

		const ScreenPtr &	GetScreen ()				{ return _currentScreen; }

		void SetScreen (const ScreenPtr &screen);
	};


	
/*
=================================================
	SetScreen
=================================================
*/
	inline void UserInterface::SetScreen (const ScreenPtr &screen)
	{
		if ( _currentScreen.IsNotNull() )
			_currentScreen->OnDetached();

		_currentScreen = screen;

		if ( _currentScreen.IsNotNull() )
			_currentScreen->OnAttached();
	}


}	// UI
}	// Engine